﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using System.Diagnostics.Contracts;

namespace ShredTheLog.Common
{
    public static class Helper
    {
        public static string GetPropertyName<T>(System.Linq.Expressions.Expression<Func<T>> property)
        {
            Contract.Requires(property != null);
            Contract.Ensures(!String.IsNullOrWhiteSpace(Contract.Result<string>()));

            string result = ((System.Linq.Expressions.MemberExpression)property.Body).Member.Name;
            Contract.Assume(!String.IsNullOrWhiteSpace(result));
            return result;
        }
    }
}
